<template>
  <div>
    <div class="demo-vertical-spacing" style="height:500px">
      <div id="echartContainerboxchart" style="width:100%; height:100%"></div>
    </div>
  </div>
</template>

<style>
.echarts {
  height: 300px !important;
  width: 100% !important;
}
</style>

<script>
// import ECharts from 'vue-echarts/components/ECharts.vue'

// import 'echarts/lib/chart/line'
// import 'echarts/lib/chart/bar'
// import 'echarts/lib/chart/pie'
// import 'echarts/lib/component/tooltip'
// import 'echarts/lib/component/legend'

let echarts = require("echarts/lib/echarts");
let prepareBoxplotData = require("echarts/extension/dataTool/prepareBoxplotData");
require("echarts/lib/chart/bar");
require("echarts/lib/chart/boxplot");
require("echarts/lib/chart/scatter");
require("echarts/lib/component/tooltip");
require("echarts/lib/component/toolbox");
require("echarts/lib/component/legend");
require("echarts/lib/component/markLine");
console.log(prepareBoxplotData);
var data = prepareBoxplotData([
    [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980, 930, 650, 760, 810, 1000, 1000, 960, 960],
    [960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790, 810, 880, 880, 830, 800, 790, 760, 800],
    [880, 880, 880, 860, 720, 720, 620, 860, 970, 950, 880, 910, 850, 870, 840, 840, 850, 840, 840, 840],
    [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920, 890, 860, 880, 720, 840, 850, 850, 780],
    [890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870, 810, 740, 810, 940, 950, 800, 810, 870]
]);
console.log(data);
export default {
  name: "ScoreCardBoxChart",
  metaInfo: {
    title: "Vue Echarts - Charts"
  },
  components: {},
  data: () => ({}),
  mounted() {
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById("echartContainerboxchart"));
    //console.log("ddddddd");
    // 绘制图表
    myChart.setOption({
      title: [
        {
            text: 'Michelson-Morley Experiment',
            left: 'center',
        },
        {
            text: 'upper: Q3 + 1.5 * IRQ \nlower: Q1 - 1.5 * IRQ',
            borderColor: '#999',
            borderWidth: 1,
            textStyle: {
                fontSize: 14
            },
            left: '10%',
            top: '90%'
        }
    ],
    tooltip: {
        trigger: 'item',
        axisPointer: {
            type: 'shadow'
        }
    },
    grid: {
        left: '10%',
        right: '10%',
        bottom: '15%'
    },
    xAxis: {
        type: 'category',
        //data: data.axisData,
        data: ['打分卡A','打分卡B','打分卡C','打分卡D','打分卡E'],
        boundaryGap: true,
        nameGap: 30,
        splitArea: {
            show: false
        },
        // axisLabel: {
        //     formatter: 'expr {value}'
        // },
        splitLine: {
            show: false
        }
    },
    yAxis: {
        type: 'value',
        name: '得分',
        splitArea: {
            show: true
        }
    },
    series: [
        {
            name: 'boxplot',
            type: 'boxplot',
            data: data.boxData,
            tooltip: {
                formatter: function (param) {
                    return [
                        'Experiment ' + param.name + ': ',
                        'upper: ' + param.data[5],
                        'Q3: ' + param.data[4],
                        'median: ' + param.data[3],
                        'Q1: ' + param.data[2],
                        'lower: ' + param.data[1]
                    ].join('<br/>')
                }
            }
        },
        {
            name: 'outlier',
            type: 'scatter',
            data: data.outliers
        }
    ]
    });
  }
};
</script>
